/**
 * FileName: OrderFrameDecoder
 * Author:   powersi
 * Date:     2021/2/28 17:20
 * Description:
 */
package com.zm.demo.netty.action.server.codec;

import com.zm.demo.netty.action.common.ResponseMessage;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

/**
 * Description: 
 * Author:      powersi
 * Date:        2021/2/28 17:20
 */
public class OrderProtocolEncoder extends MessageToMessageEncoder<ResponseMessage> {
    @Override
    protected void encode(ChannelHandlerContext ctx, ResponseMessage responseMessage, List<Object> out) throws Exception {
        ByteBuf byteBuf = ctx.alloc().buffer();
        responseMessage.encode(byteBuf);
        out.add(responseMessage);
    }
}
